package com.yh.serivicelmpl;


import com.yh.dao.AdminDao;
import com.yh.dao.StudentDao;
import com.yh.dao.TeacherDao;
import com.yh.daoimpl.AdminDaoImpl;
import com.yh.daoimpl.StudentDaoImpl;
import com.yh.daoimpl.TeacherDaoImpl;
import com.yh.javabean.Admin;
import com.yh.javabean.Student;
import com.yh.javabean.Teacher;
import com.yh.serivice.AdminService;


/**
 * @Auther: Liang
 * @Date: 2024/4/2 - 04 - 02 - 10:06
 * @Description: com.sms.serviceimpl
 * @version: 1.0
 */
public class AdminServiceImpl implements AdminService {
    StudentDao studentDao = new StudentDaoImpl();
    TeacherDao teacherDao = new TeacherDaoImpl();
    AdminDao adminDao = new AdminDaoImpl();

    /*
     * 添加学生信息*/
    @Override
    public void addStudent(String username, String password, String name,Double score) {
        Student s = new Student(username, password, name,score);
        studentDao.insert(s);
    }

    /*
     * 通过sid删除学生信息*/
    @Override
    public void removeStudent(int sid) {
        studentDao.deleteBysid(sid);
    }

    /*
     * 通过sid修改密码*/
    @Override
    public void restStudentPassword(int sid, String password) {
        studentDao.updatePasswordBySid(sid, password);
    }

    //------------------------------------------------------
    @Override
    public void addTeacher(String username, String password, String tname, String tdesc) {
        Teacher teacher = new Teacher(username, password, tname, tdesc);
        teacherDao.insert(teacher);
    }

    @Override
    public void removeTeacher(int tid) {
           teacherDao.deleteBytid(tid);
    }

    @Override
    public void restTeacherPassword(int tid, String password) {
           teacherDao.updatePasswordBytid(tid, password);
    }

    //--------------------------------------------------------------------------
    @Override
    public void addAdmin(String username, String password, String desc) {
        Admin admin = new Admin(username, password, desc);
        adminDao.insert(admin);
    }

    @Override
    public void removeAdmin(int id) {
         adminDao.deleteByid(id);
    }

    @Override
    public void restAdminPassword(int id, String password) {
       adminDao.updatePasswordByid(id,password);
    }
}
